<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <!-- <meta name="viewport" content="width=device-width, initial-scale=1.0"> -->

    <link rel="stylesheet" type="text/css" href="/css/dept/deptManagement.css"/>
    <link rel="stylesheet" type="text/css" href="/lib/easyui/themes/easyui.css"/>
    <link rel="stylesheet" type="text/css" href="/lib/easyui/themes/icon.css"/>
    <link rel="stylesheet" type="text/css" href="/css/base.css"/>
    <link rel="stylesheet" type="text/css" href="/css/news/center.css"/>
    <link rel="stylesheet" type="text/css" href="/lib/laydate.css"/>
    <link rel="stylesheet" type="text/css" href="/css/dept/new_news.css"/>
    <script type="text/javascript" src="/js/jquery/jquery-1.9.1.js"></script>
    <script src="/lib/laydate.js"></script>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <link rel="stylesheet" href="/css/base.css">
    <script src="../js/jquery/jquery-1.9.1.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery-1.8.3.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.ui.widget.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.iframe-transport.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.fileupload.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/layer/layer.js?20201106" type="text/javascript" charset="utf-8"></script>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="../lib/pagination/js/jquery.pagination.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="/js/base/tablePage.js"></script>
    <script src="/lib/laydate/laydate.js"></script>
    <script src="/lib/jquery.form.min.js"></script>
    <script src="../js/jquery/jquery.cookie.js"></script>
    <script src="../lib/ueditor/ueditor.config.js" type="text/javascript" charset="utf-8"></script>
    <script src="../lib/ueditor/ueditor.all.js" type="text/javascript" charset="utf-8"></script>


    <title><fmt:message code="global.page.first" /></title>
    <style>
        .noDatas {
            margin-top: 10px;
        }

        .noDatas_pic {
            margin-top: 20%;
        }

        .noData_out {
            margin: 0 auto;
            text-align: center;
        }

        .foot_span_show {
            float: right;
            color: white;
            line-height: 28px;
            margin-right: 15px;
            cursor: pointer
        }

        .head_rig h1 {
            width: 78px;
            height: 30px;
            font-size: 13px !important;
            background-image: url(../img/workflow/btn_new_nor_03.png), url(../img/workflow/icon_plus_03.png);
            cursor: pointer;
            background-repeat: no-repeat;
        }

        #cont_left::-webkit-scrollbar-corner {
            background: #82AFFF;
        }

        .head_rig {
            width: 480px;
            margin-top: 8px;
            float: right !important;;
        }
        .head_rig h1 {
            float: left;
            margin-right:20px;
        }

        .inp {
            height: 24px;
        }

        .search {
            width: 72px;
            height: 29px;
            margin-top: 16px;
            background: #fff;
        }

        .search h1 {
            text-align: center;
            color: #fff;
            font-size: 14px;
            line-height: 28px;
            background-image: url(../img/workflow/btn_check_nor_03.png);
            background-repeat: no-repeat;
        }

        .cont {
            width: 102%;
            height: 95%;
            overflow-y: scroll;
        }

        .head {
            border-bottom: 1px solid #9E9E9E;
            padding-bottom: 0;
            height: 45px;
        }
        .head h1{
            line-height: 45px;
            margin-left: 12px;
            color: #333;
        }
        .head_left img{
            margin-top: 12px;
        }
        .new_excell_pic {
            border-radius: 0;
            border: none;
            width: 73px;
            height: 73px;
            margin: 10px 24px 10px 20px;
        }

        .head_rig h1 :hover {
            cursor: pointer;
        }

        .deldel {
            color: #fff;
            font-size: 12px;
            float: right;
            margin-right: 10px;
            margin-left: 5px;
            line-height: 28px;
            cursor: pointer;
        }



        .footer_span_space {
            color: #fff;
            font-size: 12px;
            float: right;
            margin-right: 10px;
            line-height: 28px;
            cursor: pointer;
        }

        .foot_span_show {
            margin-left: 9px;
        }

        .edit {
            color: #fff;
            font-size: 12px;
            float: right;
            margin-right: 10px;
            margin-left: 5px;
            line-height: 28px;
            cursor: pointer;
        }

        .search h1 :hover {
            cursor: pointer;
        }

        .deldel_img {
            float: right;
            height: 15px;
            margin-top: 7px;
        }

        .edit_img {
            float: right;
            height: 15px;
            margin-top: 7px;
        }

        .deldel_yulan {
            float: right;
            height: 15px;
            margin-top: 7px;
            margin-right: 0px;
            cursor: pointer;
            margin-left: -4px;
        }

        .new_excell_footer {
            width: 100%;
            height: 28px;
            position: relative;
            background-color: #59bdf0;
        }

        .new_excell_head {
            position: relative;
            width: 100%;
            height: 30px;
        }

        .new_excell_name {
            border-left: 4px solid #59bdf0;
            color: #59bdf0;
            position: absolute;
            bottom: 0;
            font-size: 16px;
            font-weight: 700;
            height: 24px;
            margin-left: 20px;
        }

        .new_excell_info {
            width: 100%;
            height: 123px;
            position: relative;
        }

        .new_excell_center {
            margin-left: 6%;
            margin-top: 10px;
        }

        .new_excell_info_main {
            width: 100%;
            height: 62px;
            position: absolute;

        }

        .new_excell_info_other {
            position: absolute;
            top: 10px;
            height: 100%;
            margin-left: 45px;
            margin-top: 10px;
            list-style-type: none;
            left: 20%;
        }

        .new_excell_main {
            width: 332px;
            height: 181px;
            border: 1px solid #ddd;
            margin: auto;
            margin-top: 10px;
            border-radius: 5px;
        }

        .new_excell_main:hover {
            border: 2px solid #59bdf0;
        }

        .new_excell_info_mian_pic {
            float: left;
        }

        .new_excell {
            width: 360px;
            height: 191px;
            float: left;
            margin-left: 0px;
            margin-right: 0px;
        }

        .new_excell_info_other span {
            margin-left: 10px;
            color: black;
        }

        .new_excell_info_other li {
            height: 50%;
            line-height: 24px;
            font-size: 20px;
        }
        li {
            display: list-item;
            text-align: -webkit-match-parent;
        }

        .conter {
            width: 461px;
            height: 800px;
            margin: auto;
        }

        .f_field_title {
            display: inline-block;
            font-size: 12px;
            font-weight: bold;
            height: 18px;
            line-height: 41px;
            margin-left: 2px;
            margin-right: 2px;
        }

        .f_field_required {
            color: red;
            font-size: 12px;
            margin-top: 0px;
            margin-left: 2px;
            margin-right: 2px;
        }

        .f_field_ctrl {
            margin-top: 5px;
            margin-left: 2px;
            float: left;
        }
        select {
            height: 32px;
            width: 207px;
            border-radius: 4px;
            border: 1px solid #cccccc;
            background-color: #ffffff;
        }

        .f_field_title {
            font-size: 12px;
            font-weight: bold;
            margin-left: 2px;
            margin-right: 2px;
        }

        .f_field_required {
            color: red;
            font-size: 12px;
            margin-top: 0px;
            margin-left: 2px;
            margin-right: 2px;
        }

        .f_field_ctrl {
            margin-top: 5px;
            margin-left: 2px;
        }

        .f_field_ctrl input {
            color: #000;
        }

        .f_field_block {
            width: 100%;
            height: 68px;
            margin-top: 70px;
            margin-bottom: 4px;
            display: block;
            text-align: left;
        }

        .inp {
            width: 221px;
            height: 32px;
            border-radius: 4px;
        }

        /*	#layui-layer2{
                border-radius:10px;
            }*/
        .center {
            height: 400px !important;
        }

        .delete_flow, .edit_liucheng {
            cursor: pointer;
        }

        .layui-layer-title {
            padding: 0 80px 0 20px;
            height: 42px;
            line-height: 42px;
            border-bottom: 1px solid #eee;
            font-size: 16px;
            color: #fff;
            overflow: hidden;
            background-color: #2b7fe0;
            border-radius: 2px 2px 0 0;
        }

        .layui-layer-page .layui-layer-btn {
            padding-top: 10px;
            text-align: center;
        }
        .tit{
            position: absolute;
            float: none;
            color: #999;
            margin-left: 5px;
        }
        .nav_box .nav_t2{
            color: #333;
        }
        table{
            margin-left: 30px;
        }
        @media screen and (max-width: 1366px) {
            .shab{
                padding-left: 80px;
                position: relative;
                left: -39px;
            }
            .nav_box .head_rig .new_dept{
                width: 80px;
                height: 30px;
                font-size: 13px !important;
                cursor: pointer;
                background-repeat: no-repeat;
                color: #fff;
                padding-left: 22px;
            }
        }
        .edui-default{
            margin-left:0px;
        }
        .new_but {
            height: 34px;
            margin-left: 45%;
        }

    </style>
</head>
<body style="overflow:scroll;overflow-y: auto;overflow-x:hidden;">
<%--新建组织--%>
<div class="step1" style="display: block;margin-left: 0px;">
    <!-- 中间部分 -->
    <div class="nav_box clearfix">
        <div class="nav_t1" style="margin-left: 30px;"><img src="/img/bumen.png"></div>
        <div class="nav_t2" class="news" style="font-size: 20px;">编辑查看组织</div>
        <%--        <div class="head_rig" id="head_rig2" style="width:190px;">--%>
        <%--            <h1 style='cursor:pointer;color: white' class="delete_but" name="del" id="delete" onclick="delDept()" >删除</h1>--%>
        <%--            &lt;%&ndash;<h1 style='cursor:pointer;' class="export" onclick="develop()"><fmt:message code="global.lang.report" /></h1>&ndash;%&gt;--%>
        <%--        </div>--%>
        <%--        <div class="head_rig" id="head_rig" style="width:190px;">--%>
        <%--            <h1 style='cursor:pointer;' class="new_dept" onclick="newDept()" ><fmt:message code="depatement.th.NewDepartment" /></h1>--%>
        <%--            &lt;%&ndash;<h1  class="import" onclick="develop()"><fmt:message code="workflow.th.Import" /></h1>&ndash;%&gt;--%>
        <%--            &lt;%&ndash;<h1 style='cursor:pointer;' class="export" onclick="develop()"><fmt:message code="global.lang.report" /></h1>&ndash;%&gt;--%>
        <%--        </div>--%>
        <%--        <div class="head_rig" id="head_rig1" style="width:190px;">--%>
        <%--            <h1 class="import" id="import" ><fmt:message code="workflow.th.Import" /></h1>--%>
        <%--            &lt;%&ndash;<h1 style='cursor:pointer;' class="export" onclick="develop()"><fmt:message code="global.lang.report" /></h1>&ndash;%&gt;--%>
        <%--        </div>--%>

    </div>

    <table class="newNews">

        <tbody>
        <tr>
            <td class="td_w blue_text">
                组织排序号
            </td>
            <td style="position:relative;">
                <input class="td_title1" type="text" placeholder="" id="deptNo"/>
                <img class="td_title2" src="../img/mg2.png" alt="">
                <div class="tit">  3位数字，用于同一级次组织排序，不能重复</div>

            </td>
        </tr>
        <tr>
            <td class="td_w blue_text">
                党组织名称
            </td>
            <td>
                <input class="td_title1" id="deptName" type="text" placeholder=""/>
                <img class="td_title2" src="../img/mg2.png" alt="">

            </td>
        </tr>
        <tr>
            <td class="td_w blue_text">
                <span style="border-bottom: 1px solid #fff;">坐标<b style="color: red;">*</b></span>
            </td>
            <td>
                <label style="width: 47%;position:relative">
                    <input type="text" name="gridLocation" style="width:200px" readonly="readonly">
                    <button type="button" class="dwbtn" style="position: absolute;width: 66px;height: 30px; background-color: #228cdc;color: #fff; right: 0px;top:-4px;border-radius: 3px;cursor: pointer;">点击定位</button>
                </label>
            </td>
        </tr>
        <tr>
            <td class="td_w blue_text">
                上级组织
            </td>
            <td>
                <%--<select name="DEPT_PARENT" class="BigSelect" id="deptParent">
                </select>--%>
                <input class="td_title1" type="text" style="background-color: #e7e7e7;width: 200px"  id="deptParent" deptParentId="" readonly />

                <a class="release3 addDept">添加</a>
                <a class="release3 clearDept">清除</a>
            </td>
        </tr>
        <tr>
            <td class="blue_text">支部书记</td>
            <td>
                <input class="td_title1  release1" id="query_toId" type="text" readonly/>
                <%-- <img class="td_title2 release2" id="ip2" src="../img/mg2.png" alt=""/>--%>
                <div class="release3" id="adduserAssistant"><fmt:message code="global.lang.add" /></div>
                <div class="release4 empty" onclick="empty('query_toId')"><fmt:message code="global.lang.empty" /></div>

            </td>
        </tr>
        <tr>
            <td class="blue_text">
                电话
            </td>
            <td>
                <input class="td_title1 time_coumon" id="faxNo" type="text" placeholder=""/>

            </td>
        </tr>
        <tr>
            <td class="blue_text">
                副书记数
            </td>
            <td>
                <input class="td_title1 time_coumon" id="orgVicelerk" type="text" placeholder=""/>

            </td>
        </tr>
        <tr>
            <td class="blue_text">
                委员数
            </td>
            <td>
                <input class="td_title1 time_coumon" id="orgCouncil" type="text" placeholder=""/>

            </td>
        </tr>
        <tr>
            <td class="blue_text">
                任期
            </td>
            <td>
                <input class="td_title1 time_coumon" id="orgTenure" type="text" placeholder=""/>

            </td>
        </tr>
        <tr>
            <td class="blue_text">
                上次换届时间
            </td>
            <td>
                <input class="td_title1 time_coumon" id="orgOldDate" type="text" placeholder="" onclick="laydate({istime: true, format: 'YYYY-MM-DD'})"/>

            </td>
        </tr>
        <tr>
            <td class="blue_text">
                本次换届时间
            </td>
            <td>
                <input class="td_title1 time_coumon" id="orgNewDate" type="text" placeholder="" onclick="laydate({istime: true, format: 'YYYY-MM-DD'})"/>

            </td>
        </tr>
        <tr>
            <td class="blue_text">
                党组织书记
            </td>
            <td>
                <input class="td_title1 time_coumon" id="orgUserorg" type="text" placeholder="" />

            </td>
        </tr>
        <tr>
            <td class="blue_text">
                联系方式
            </td>
            <td>
                <input class="td_title1 time_coumon" id="orgIphone" type="text" placeholder="" />

            </td>
        </tr>
        <tr>
            <td class="blue_text">
                <fmt:message code="depatement.th.address" />
            </td>
            <td>
                <input class="td_title1 time_coumon" id="deptAddress" type="text" placeholder=""/>

            </td>
        </tr>
        <tr>
            <td class="blue_text">
                划分党小组数量
            </td>
            <td>
                <input class="td_title1 time_coumon" id="orgOrgconut" type="text" placeholder=""/>

            </td>
        </tr>
        <tr>
            <td class="blue_text">
                非公企业数
            </td>
            <td>
                <input class="td_title1 time_coumon" id="orgFeigong" type="text" placeholder=""/>

            </td>
        </tr>
        <tr>
            <td class="blue_text">
                非公指导员数
            </td>
            <td>
                <input class="td_title1 time_coumon" id="orgZhidao" type="text" placeholder=""/>

            </td>
        </tr>
        <tr>
            <td class="blue_text">
                流动党员数
            </td>
            <td>
                <input class="td_title1 time_coumon" id="orgLiudong" type="text" placeholder=""/>

            </td>
        </tr>
        <tr>
            <td class="blue_text">
                备注
            </td>
            <td>
                <textarea name="orgRemark" id="orgRemark" style="width:400px;height:75px ;"></textarea>

            </td>
        </tr>
        <tr>
            <td class="blue_text shab">
                简介
            </td>
            <td>
                <%--<textarea style="font-size: 27px;" name="" cols="60" rows="3" id="deptFunc"></textarea>--%>
                <div id="container" type="text/plain" style="width: 94%;min-height: 100px;margin:0 auto;"></div>
            </td>
        </tr>
        <tr>
            <td width="25%" class="blue_text">组织照片</td>
            <td>

                <form id="uploadimgform" style="height: 30px;" target="uploadiframe"  action="../upload?module=photo" enctype="multipart/form-data" method="post">
                    <input type="file" multiple="multiple" name="file" id="uploadinputimg"  class="w-icon5" style="position: absolute;opacity: 0;width: 70px;cursor:pointer;
                        filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0)">
                    <a id="uploadimg" style="cursor: pointer;color:#2F8AE3;padding-left:20px;float:left;line-height: 57px;">附件上传</a>
                    <div id="query_uploadArr" style="    margin: 17px;display: block;float:left">
                    </div>
                </form>
            </td>
        </tr>
        <tr>
            <td colspan="2" style="height: 29px;top:-29px;position: relative;">
                <%--                <button data-type="0" type="button" class="new_but" id="new" style="position: absolute;top: 38px;left: 50%;margin-left: -42px;color: #fff;">保存</button>--%>

                <button data-type="0" type="button" class="new_but" id="new" style="margin-top: 38px;display: inline-block;margin-right: 10px;line-height: 1;font-size:18px;padding: 8px 20px;background: #2F8AE3;color: #fff;border-radius: 6px">保存</button>
                <button data-type="0" type="button" class="getBack" style="margin-top: 38px;display: inline-block;line-height: 1;font-size:18px;padding: 8px 20px;background: #2F8AE3;color: #fff;border-radius: 6px;">关闭</button>
            </td>
        </tr>

        </tbody>
    </table>
</div>

</body>

<script>
    function getQueryString(name){
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if(r!=null)return  unescape(r[2]); return null;
    }
    var orgDeptId = getQueryString('orgDeptId')
    var isEdit = getQueryString("isEdit");
    //console.log(isEdit);

    //返回
    $('.getBack').click(function(){
        // $('.tableList').show();
        // $('.mainBg').hide();
        /*window.location.href="/street/partyList";*/
        window.close();
    })

    //  设置坐标
    function setZuobiao(str){
        $('input[name="gridLocation"]').val(str)
    }
    var dd=$.cookie('meId')
    //console.log(dd)
    $(function () {

        //    点击坐标定位
        $('.dwbtn').click(function () {
            // window.open('/street/chooseMap')
            window.open('/street/mapCoordinates?type=4')
        })
            $.ajax({
                //url: '/orgDepartment/queryByIdOrgDepartmentWithBLOBs?deptId=' + dd,
                url:'/orgDepartment/getPartyDeptById?orgDeptId=' + orgDeptId,
                type: 'get',
                dataType: 'json',
                success: function (reg) {
                    $.cookie('meId',1, { expires: 7 , path: '/' });
                    var datas = reg.object;

                    $('input[name="gridLocation"]').val(datas.gridLocation)

                    $("#deptParent").attr("deptParentName",datas.orgDeptParentName);
                    $("#deptName").val(datas.orgDeptName);  // 组织名称
                    $("#faxNo").val(datas.orgTelNo); //传真
                    $("#deptAddress").val(datas.orgDeptAddress);//组织地址
                    $("#deptNo").val(datas.orgDeptNo)//  组织排序号

                    $("#query_toId").val(datas.orgOrgAdmin)//组织管理员

                    $('#orgVicelerk').val(datas.orgVicelerk),
                        $('#orgCouncil').val(datas.orgCouncil),
                        $('#orgTenure').val(datas.orgTenure),
                        $('#orgOldDate').val(datas.orgOldDate),
                        $('#orgNewDate').val(datas.orgNewDate),
                        $('#orgOrgconut').val(datas.orgOrgconut),
                        $('#orgUserorg').val(datas.orgUserorg),
                        $('#orgIphone').val(datas.orgIphone),
                        $('#orgFeigong').val(datas.orgFeigong),
                        $('#orgZhidao').val(datas.orgZhidao),
                        $('#orgLiudong').val(datas.orgLiudong),
                        $('#orgRemark').val(datas.orgRemark)
                    $('#deptParent').val(datas.orgDeptParentName);
                    $('#deptParent').attr("deptparentid",datas.orgDeptParent);
                    var ue = UE.getEditor('container');
//                console.log(ue)
                    ue.addListener("ready", function () {
//                    console.log(ue)
                        ue.setContent(datas.orgDeptFunc,false);
                    });//内容

                    var arr = datas.attachmentList;
                    var str1=""
                    if (datas.attachmentList != '') {
                        for (var i = 0; i < (arr.length); i++) {
                            str1+='<div class="dech" deUrl="'+encodeURI(arr[i].attUrl)+'" style="display:block;"><a class="ATTACH_a" NAME="'+arr[i].attachName+'*" href="<%=basePath %>download?'+encodeURI(arr[i].attUrl)+'">'+arr[i].attachName+'</a><img class="deImgs" style="margin-left:5px;cursor: pointer;" src="../img/file/icon_deletecha_03.png"/><input type="hidden" NAME="'+arr[i].attachName+'*"  class="inHidden" value="'+arr[i].aid+'@'+arr[i].ym+'_'+arr[i].attachId+',"></div>';
                        }
                        $('#query_uploadArr').append(str1);
                    };
                }
            })

    })
    //    user_id='query_toId';//选人控件
    /* 人员控件清空 */

    var user_id;
    var dept_id;
    function empty(id){
        $("#"+id).val("");
    };
    //        获取ue编辑器
    var ue = UE.getEditor('container');


    $(function(){

        var table_width = $('.step1').width()-85;

        $('.newNews').width(table_width);
        /*$("#deptParent").deptSelect(); //新建中上级组织中组织控件
        $("#deptParent_").deptSelect(); //编辑中上级组织中组织控件*/

        // 获取组织信息控件
        // $(".addDept").on("click",function(){
        //     dept_id='deptParent';
        //     $.popWindow("../common/selectDeptshiyuan?0");
        // });

        //选上级组织控件
        $(".addDept").on("click", function () {
            dept_id = 'deptParent';
            $.popWindow("../../common/selectDeptshiyuan?0");
            editAdd=0;
        });
        //选支部书记控件
        $("#adduserAssistant").on("click", function () {
            user_id = 'td_title1';
            $.popWindow("../../common/selectUser?0");
            editAdd=0;
        });

        // 清空组织信息
        $('.clearDept').click(function () {
            $('#deptParent').attr("deptid","");
            $('#deptParent').attr("deptno","");
            $('#deptParent').val("");
        });


        /* 选人控件 */
        $("#adduserAssistant").on("click",function(){
            user_id = "query_toId";
            $.popWindow("../common/selectUsershiyuan?0");
        });
        // $("#adduserAssistant_").on("click",function(){
        //     user_id = "query_toId_";
        //     $.popWindow("../common/selectUsershiyuan?0");
        // });


        var fileId="";
        var fileName="";

        // 新建组织的
        $("#new").click(function(){

//            if($('#deptParent').val()==''){
//                $.layerMsg({content:'请选择上级组织',icon:7})
//                return false;
//            }
            if(isEdit == "false"){
                $("#new").attr("data-type","1") ;
                if($("#new").attr('data-type') == 1){
                    var deptParentValue = $('#deptParent').attr('deptid')|| 0;
                    if(deptParentValue != 0){
                        var deptParentValue = deptParentValue.split(',')[0];
                    }

                    for(var i=0;i<$('.inHidden').length;i++){
                        fileId += $('.inHidden').eq(i).val();
                        fileName += $('.inHidden').eq(i).attr('name');
                    }
                    var ue = UE.getEditor('container');
                    var con=""
                    ue.addListener("ready", function () {
                        con=ue.getContent();
                    });//内容


                    var data = {
                        "attachmentId":fileId,
                        "attachmentName":fileName,
                        "orgDeptName": $("#deptName").val().split(',')[0],    // 组织名称
                        "orgTelNo":$("#faxNo").val(),  //传真
                        "orgDeptAddress": $("#deptAddress").val(),// 组织地址
                        "orgDeptNo":   $("#deptNo").val().split(',')[0],//  组织排序号
                        "orgDeptParent":  deptParentValue,//上级组织ID
//                "orgOrgAdmin": $("#query_toId").attr("dataid"),//组织管理员
                        "orgOrgAdmin": $("#query_toId").val(),//组织管理员
                        "orgDeptFunc":ue.getContent(),//组织职能
                        "gridLocation":$('input[name="gridLocation"]').val(),
                        'orgVicelerk':$('#orgVicelerk').val(),
                        'orgCouncil':$('#orgCouncil').val(),
                        'orgTenure':$('#orgTenure').val(),
                        'orgOldDate':$('#orgOldDate').val(),
                        'orgNewDate':$('#orgNewDate').val(),
                        'orgOrgconut':$('#orgOrgconut').val(),
                        'orgUserorg':$('#orgUserorg').val(),
                        'orgIphone':$('#orgIphone').val(),
                        'orgFeigong':$('#orgFeigong').val(),
                        'orgZhidao':$('#orgZhidao').val(),
                        'orgLiudong':$('#orgLiudong').val(),
                        'orgRemark':$('#orgRemark').val(),
                    };
                    if($('#deptNo').val()=='' || $('#deptNo').val().length>3){
                        layer.msg('请填写组织排序号,最多3个字符', { icon:6});
                        return false;
                    }else if($('#deptName').val()==''){
                        layer.msg('请填写组织名称', { icon:6});
                        return false;
                    }else{
                        $.ajax({
                            url:"/orgDepartment/addOrgDepartment",
                            type:'post',
                            dataType:"JSON",
                            data : data,
                            success:function(data){

                                if(data.flag){
                                    $.layerMsg({content:'新建成功！',icon:1},function(){
                                        location.reload();
                                        window.close();
//                                setTimeout("window.location.href='/street/oranges'",2000);
                                    });
                                }else{
                                    if(data.msg == '该组织名称或排序号已经存在，请重新填写！'){
                                        $.layerMsg({content:'该组织名称或排序号已经存在，请重新填写！',icon:1},function(){
                                            //location.reload();
                                        })
                                    }else{
                                        $.layerMsg({content:'新建失败！',icon:1},function(){
                                            //   location.reload();
                                        })
                                    }
                                }

                            },
                            error:function(e){
                                console.log(e);
                            }
                        });

                    }
                }
            } else {
                var deptParentValue = $('#deptParent').attr('deptid')|| 0;
                if(deptParentValue != 0){
                    var deptParentValue = deptParentValue.split(',')[0];
                }else{
                    deptParentValue=$('#deptParent').attr('deptParentId');
                }
                for(var i=0;i<$('.inHidden').length;i++){
                    fileId += $('.inHidden').eq(i).val();
                    fileName += $('.inHidden').eq(i).attr('name');
                }
                var ue = UE.getEditor('container');
                var con=""
                ue.addListener("ready", function () {
                    con=ue.getContent();
                });
                var data = {
                    "attachmentId":fileId,
                    "attachmentName":fileName,
                    "orgDeptName": $("#deptName").val().split(',')[0],    // 组织名称
                    "orgTelNo":$("#faxNo").val(),  //传真
                    "orgDeptAddress": $("#deptAddress").val(),// 组织地址
                    "orgDeptNo":   $("#deptNo").val().split(',')[0],//  组织排序号
                    "orgDeptParent":  deptParentValue,//上级组织ID
                    "orgOrgAdmin": $("#query_toId").val(),//组织管理员
                    "orgDeptFunc":ue.getContent(),//组织职能
                    "gridLocation":$('input[name="gridLocation"]').val(),
                    'orgVicelerk':$('#orgVicelerk').val(),
                    'orgCouncil':$('#orgCouncil').val(),
                    'orgTenure':$('#orgTenure').val(),
                    'orgOldDate':$('#orgOldDate').val(),
                    'orgNewDate':$('#orgNewDate').val(),
                    'orgOrgconut':$('#orgOrgconut').val(),
                    'orgUserorg':$('#orgUserorg').val(),
                    'orgIphone':$('#orgIphone').val(),
                    'orgFeigong':$('#orgFeigong').val(),
                    'orgZhidao':$('#orgZhidao').val(),
                    'orgLiudong':$('#orgLiudong').val(),
                    'orgRemark':$('#orgRemark').val(),
                };
                if($('#deptNo').val()=='' || $('#deptNo').val().length>3){
                    layer.msg('请填写组织排序号,最多3个字符', { icon:6});
                    return false;
                }else if($('#deptName').val()==''){
                    layer.msg('请填写组织名称', { icon:6});
                    return false;
                }else{
                    $.ajax({
                        url:'/orgDepartment/updateOrgDepartment?orgDeptId='+orgDeptId,
                        type:'post',
                        dataType:"JSON",
                        data : data,
                        success:function(data){

                            if(data.flag){
                                $.layerMsg({content:'保存成功！',icon:1},function(){
                                    /*location.reload();*/
                                    window.close();
//                                setTimeout("window.location.href='/street/oranges'",2000);
                                });
                            }else{
                                if(data.msg == '该组织名称或排序号已经存在，请重新填写！'){
                                    $.layerMsg({content:'该组织名称或排序号已经存在，请重新填写！',icon:1},function(){
                                        //location.reload();
                                    })
                                }else{
                                    $.layerMsg({content:'保存失败！',icon:1},function(){
                                        //   location.reload();
                                    })
                                }
                            }

                        },
                        error:function(e){
                            console.log(e);
                        }
                    });

                }
            }



        });
        //新建下级组织
        $("#newdeptDown").on("click",function(){
            $(".step1").show();
            $(".step2").hide();
            var deptNo_ = $("#deptNo_").val() + ',';
            var deptName_ = $("#deptName_").val() + ',';
            var newbumen=$("#dapaId_").text() + ',';
            $('#deptParent').val(deptName_);
            $('#deptParent').attr('deptid',newbumen);
            $('#deptParent').attr('deptno',deptNo_);


        })




    });
    var pid = $.GetRequest().id;
    function delDept(){
        $.ajax({
            type:'post',
            url:'/orgDepartment/delDepartment?deptId='+pid,
            dataType:'json',
            success:function(res){
                if(res.flag){
                    $.layerMsg({content:'删除成功！',icon:1});
                }else{
                    $.layerMsg({content:'删除失败！',icon:1});

                }

            }
        })
        window.parent.location.reload();
    }



    function newDept(){
        var ue = UE.getEditor('container');
        ue.addListener("ready", function () {
            ue.setContent('');
        });//内容
        $(".td_title1").val('');
        $("#deptName").val('');  // 组织名称
        $("#faxNo").val(''); //传真
        $("#deptAddress").val('');//组织地址
        $("#deptNo").val('')//  组织排序号
        $("#query_toId").val('')//组织管理员
        $('input[name="gridLocation"]').val('')
        $('#orgVicelerk').val(''),
            $('#orgCouncil').val(''),
            $('#orgTenure').val(''),
            $('#orgOldDate').val(''),
            $('#orgNewDate').val(''),
            $('#orgOrgconut').val(''),
            $('#orgUserorg').val(''),
            $('#orgIphone').val(''),
            $('#orgFeigong').val(''),
            $('#orgZhidao').val(''),
            $('#orgLiudong').val(''),
            $('#orgRemark').val('')

        $("#new").attr('data-type','1')
        $('#query_uploadArr').html('');


    }



    //        附件上传
    $('#uploadimg').click(function(){
        me=this;
        $('#uploadinputimg').click()
    })
    $('#uploadinputimg').fileupload({
        dataType:'json',
        done: function (e, data) {
            if(data.result.obj != ''){
                var data = data.result.obj;
                var str = '';
                var str1 = '';
                for (var i = 0; i < data.length; i++) {
                    var gs = data[i].attachName.split('.')[1];
                    if(gs == 'jsp'||gs == 'css'||gs == 'js'||gs == 'html'||gs == 'java'||gs == 'php' ){
                        str += '';
                        layer.alert('jsp、css、js、html、java文件禁止上传!',{},function(){
                            layer.closeAll();
                        });
                    }else{
                        str+='<div class="dech" deUrl="'+encodeURI(data[i].attUrl)+'" style="display:block;"><a class="ATTACH_a" NAME="'+data[i].attachName+'*" href="<%=basePath %>download?'+encodeURI(data[i].attUrl)+'">'+data[i].attachName+'</a><img class="deImgs" style="margin-left:5px;cursor: pointer;" src="../img/file/icon_deletecha_03.png"/><input type="hidden" NAME="'+data[i].attachName+'*"  class="inHidden" value="'+data[i].aid+'@'+data[i].ym+'_'+data[i].attachId+',"></div>';
                    }
                }
                $('#query_uploadArr').append(str);
            } else{
                //alert('添加附件大小不能为空!');
                layer.alert('添加附件大小不能为空!',{},function(){
                    layer.closeAll();
                });
            }
        }
    });
    $('#query_uploadArr').on('click','.deImgs',function(){
        var data=$(this).parents('.dech').attr('deUrl');
        var dome=$(this).parents('.dech');
        deleteChatment(data,dome);
    });

    //删除附件
    function deleteChatment(data,element){
        layer.confirm('确定要删除吗？', {<%--确定要删除吗--%>
            btn: ['确定','取消'], //按钮  <%--确定 取消--%>
            title:'删除'  <%--删除附件--%>
        }, function(){
            //确定删除，调接口
            $.ajax({
                type:'get',
                url:'../delete',
                dataType:'json',
                data:data,
                success:function(res){

                    if(res.flag == true){
                        layer.msg('删除成功', { icon:6});<%--删除成功--%>
                        element.remove();
                    }else{
                        layer.msg('删除失败', { icon:6});<%--删除失败--%>
                    }
                }
            });

        }, function(){
            layer.closeAll();
        });
    }
    //    点击导入
    //     $('#import').click(function(){
    //         layer.open({
    //             type:1,
    //             title: ['党组织信息导入', 'background-color:#2b7fe0;color:#fff;'],
    //             area: ['600px', '420px'],
    //             btn: ['导入', '取消'],
    //             content:'<div>' +
    //             '<form class="form1" name="form1" id="uploadForm" method="post" action="/orgDepartment/ecoudInsert" enctype="multipart/form-data">' +
    //             '<table class="importTable"> ' +
    //             '<tr><td style="width: 100px;">下载导入模板：</td><td style="text-align: left;"><a id="model" style="cursor:pointer">党员信息模板下载</a></td></tr>' +
    //             '<tr> <td>选择导入文件：</td> <td><input style="width: auto" type="file" name="file"/></td> </tr>' +
    //             '<tr>' +
    //             '<td>说明：</td>'+
    //             '<td style="text-align: left;"><p>1、请导入.xls文件或者.xlsx。</p>'+
    // //            '<p>2、请填写网格信息中已有网格。</p>'+
    //             ' </td> ' +
    //             '</tr>' +
    //             '</table>' +
    //             '</form>' +
    //             '</div>',
    //             success:function(){
    //                 $('#model').click(function () {
    //                     window.location.href = "/file/grid/griddzz_import.xls";
    //                 });
    //             },
    //             yes:function(obj){
    //                 var flag = CheckForm();
    //                 if (flag) {
    //                     layer.msg("正在导入中，请耐心等候", {icon: 1});
    //                     $.upload($('#uploadForm'), function (res) {
    //                         if(res.flag) {
    //                             layer.msg("导入成功", {icon: 1});
    //                         }else{
    //                             layer.msg("导入失败", {icon: 2});
    //                         }
    //                     });
    //
    //                     location.reload()
    //                 }
    //             }
    //         })
    //     })
    //     function CheckForm(){
    //         if(document.form1.file.value==""){
    //             layer.msg("请导入至少一条数据！",{icon:2});
    //             return (false);
    //         }
    //         return (true);
    //     }

</script>

</html>
